chore: Add criterion benchmarks, profiling, and optimization documentation - #531
Merged
Conversation
…ng target for V2 engine - Replace iai stub in benches/v2_engine.rs with criterion benchmarks covering four scenarios (text body, JSON equality, JSON with matching rules, headers+query), each split into build / execute / build+execute phases - Add examples/profile_engine.rs as a standalone flamegraph target - Add [profile.profiling] to workspace Cargo.toml (release speed + debug symbols) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…terpreter Change walk_tree and all execute_* methods to take ExecutionPlanNode by value instead of by reference. The interpreter now moves/transforms the plan tree into the executed tree rather than cloning it. Key changes: - walk_tree: &ExecutionPlanNode -> ExecutionPlanNode; CONTAINER and PIPELINE branches use children.into_iter() instead of VecDeque::from(children.clone()), and push(child_result) instead of push(child_result.clone()) - execute_action and all ~25 execute_* methods: owned node, destructure at top - validate_one/two/three_args and validate_args: take Vec<ExecutionPlanNode> directly, use into_iter() to move children to walk_tree - evaluate_children: takes children: Vec<ExecutionPlanNode> by value - execute_plan: clones plan_root once at entry (public API unchanged) Benchmark results (execute phase): text body: -30% JSON equality: -35% JSON with rules: -33% Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Documents the flamegraph → benchmark → fix → repeat workflow used to optimise the V2 engine, including tool setup, how to read flamegraphs, criterion baseline management, and when to stop optimising. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a comprehensive performance benchmarking and profiling workflow for the V2 matching engine, along with new tooling and documentation to support ongoing optimisation. The changes add Criterion-based benchmarks, a dedicated profiling example for flamegraph analysis, and a detailed guide for future performance work. Minor test adjustments were also made to align with recent refactoring.
Performance Benchmarking and Profiling Infrastructure:
benches/v2_engine.rsfile using Criterion, providing statistical benchmarking for four representative scenarios (text body, JSON equality, JSON with rules, headers + query) and separating plan build, execute, and end-to-end timings.examples/profile_engine.rsthat exercises all key scenarios in a tight loop, intended for use withcargo flamegraphand other profilers.[profile.profiling]build profile inCargo.tomlto enable release optimisations while retaining debug symbols, improving profiler output.pact_matching/Cargo.tomland added Criterion as a dev-dependency.Documentation:
PERFORMANCE.mdguide covering profiling tools, workflow, benchmark structure, and optimisation history, to help maintainers and contributors follow best practices for performance work.Test Adjustments:
walk_treeinwalk_tree_tests.rsto clone the node argument, matching the new function signature after recent refactoring. [1] [2] [3] [4] [5]